#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json
'''
core.porker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
扑克基类（单张 )
'''
class poker:
    '''
    Attribute
        private __displayname__:显示的名称
        private __pointnum__:点数
        private __color__:花色
        private __value__:牌面分值 (__value=__pointnum__+__color__*0.01)
    '''
    __displayname__=None  #显示名称
    __pointnum__=0 #基数数值
    __color__=0 #花色 "spade":黑桃,"heart"：红星,"diamond"：方块,"club"：梅花
    __value__=0.0 #分值
    def __init__(self,pointnum,color):
        self.__pointnum__=pointnum
        self.__color__=color
        self.__value__=pointnum+color*0.01
        if pointnum <= 10:
            self.__displayname__=str(pointnum)
        elif pointnum == 11:
            self.__displayname__="J"
        elif pointnum == 12:
            self.__displayname__="Q"
        elif pointnum == 13:
            self.__displayname__="K"
        elif pointnum == 14:
            self.__displayname__="A"
        elif pointnum == 15:
            self.__displayname__="小鬼"
            self.__value__=self.__value__*2
        elif pointnum == 16:
            self.__displayname__="大鬼"
            self.__value__=self.__value__*2

    def getName(self):
        '''
        Feature
            getName()
        Description
            获取名称
        Return
            string:扑克名称
        '''
        if self.__displayname__:
            return self.__displayname__
        return None
    def getValue(self):
        '''
        Feature
            getValue()
        Description
            获取分值
        Return
            int:分值
        '''
        if self.__value__:
            return self.__value__
        return None
    def getPoint(self):
        '''
        Feature
            getPoint()
        Description
            获取扑克点数
        Return
            int:点数
        '''
        if self.__pointnum__:
            return self.__pointnum__
        return None
    def getColor(self):
        '''
        Feature
            getColor()
        Description
            获取花色
        Return
            json:{"Key":"Value"}
                 Key
                    cn:中文
                    en:英文
                 Value
                    cn:黑桃/红心/方块/梅花
                    en:Spade/Heart/Diamond/Club
        '''
        if self.__color__:
            result={}
            if self.__color__==1:
                result={"cn":"黑桃","en":"Spade"}
            elif self.__color__==2:
                result={"cn":"红心","en":"Heart"}
            elif self.__color__==3:
                result={"cn":"方块","en":"Diamond"}
            elif self.__color__==4:
                result={"cn":"梅花","en":"Club"}
            return json.dumps(result,sort_keys=True,indent=4)
        return None